package com.itheima.inetaddress;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class Demo07 {
    public static void main(String[] args) throws IOException {
        //创建码头
        MulticastSocket ms = new MulticastSocket(10000);

        //创建小箱子
        byte[] bytes = new byte[1024];
        //创建箱子
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length);

        ms.joinGroup(InetAddress.getByName("224.0.1.0"));

        //装数据
        ms.receive(dp);
        byte[] data = dp.getData();
        int length = dp.getLength();

        System.out.println(new String(data,0,length));

    }
}
